//
//  BankCardBinDingViewController.m
//  firstpoint
//
//  Created by 泽中 on 2017/7/18.
//  Copyright © 2017年 xzcysoft. All rights reserved.
//

#import "BankCardBinDingViewController.h"
#import "BinDingTextView.h"
#import "BinDingPromptView.h"
#import "ZJBLStoreShopTypeAlert.h"

@interface BankCardBinDingViewController ()
{
    UILabel*wuliuLab;
    BinDingTextView*kaihuhangText;
    NSMutableArray *titles;//公司分类

}
@end

@implementation BankCardBinDingViewController
-(void)httpBankName
{
    NSString*tokenStr= OBJECT_FOR_KEY(@"token");
    NSString*urlStr=[NSString stringWithFormat:@"/user/bankInfo.api?access_token=%@",tokenStr];
    [HTTPURL postRequest:LINK_BASE_URL(urlStr) parameters:@{@"isPrivate":@"1"} success:^(NSURLSessionDataTask *task, id responseObject) {
        NSDictionary*dic=[PublicTools dictionaryWithJsonString:responseObject[@"data"]];
       NSArray*arr=(NSArray*)dic;
    
        [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [titles addObject:obj[@"bankName"]];
        }];;
        NSLog(@"%@",titles);
    } filure:^(NSURLSessionDataTask *task, id error) {
        
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self httpBankName];
    titles=[NSMutableArray new];
//    titles = @[@"中国银行",@"北京银行",@"廊坊银行",@"河北银行"];

    self.title=@"绑定银行卡";
    self.view.backgroundColor=LRRGBColor(235, 240, 242);
    [self setUI];
    // Do any additional setup after loading the view.
}
-(void)setUI
{
    UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 74, width_screen, 137)];
    view.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view];
    BinDingTextView*bankNunText=[[BinDingTextView alloc]initWithFrame:CGRectMake(0, 0, width_screen, 46)];
    bankNunText.titleLab.text=@"银行卡号";
    bankNunText.textField.placeholder=@"请输入银卡卡号";
    [view addSubview:bankNunText];
    
   kaihuhangText=[[BinDingTextView alloc]initWithFrame:CGRectMake(0, 46, width_screen, 46)];
    kaihuhangText.titleLab.text=@"开户行";
    kaihuhangText.textField.text=@"中国银行";
    [view addSubview:kaihuhangText];
    
    UIButton*kaihuhangButton=[[UIButton alloc]initWithFrame:CGRectMake(0, 46, width_screen, 45)];
    [kaihuhangButton addTarget:self action:@selector(tanchuWuLiuGongSi) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:kaihuhangButton];
    
   

 
    BinDingTextView*kaihuzhihangText=[[BinDingTextView alloc]initWithFrame:CGRectMake(0, 92, width_screen, 46)];
    kaihuzhihangText.titleLab.text=@"开户支行";
    kaihuzhihangText.textField.placeholder=@"支行名称";
    [view addSubview:kaihuzhihangText];

    
    
    BinDingTextView*nameText=[[BinDingTextView alloc]initWithFrame:CGRectMake(0, 221, width_screen, 46)];
    nameText.titleLab.text=@"姓名";
    nameText.textField.placeholder=@"开户人姓名";
    [self.view addSubview:nameText];
    
    BinDingTextView*phoneNumText=[[BinDingTextView alloc]initWithFrame:CGRectMake(0, 267, width_screen, 44)];
    phoneNumText.titleLab.text=@"手机号";
    phoneNumText.textField.placeholder=@"银行预留手机号";
    [self.view addSubview:phoneNumText];
    
    BinDingPromptView*tishiView=[[BinDingPromptView alloc]initWithFrame:CGRectMake(0, 321, width_screen, 80)];
    [self.view addSubview:tishiView];
    UIButton*button=[UIButton buttonWithType:UIButtonTypeCustom];
    button.frame=CGRectMake(10, 401, width_screen-20, 50);
    button.backgroundColor=LRRGBColor(23, 146, 211);
    button.layer.cornerRadius=4;
    [button setTitle:@"确认" forState:0];
    [self.view addSubview:button];
    
}
-(void)tanchuWuLiuGongSi
{
    [ZJBLStoreShopTypeAlert showWithTitle:@"选择你的银行" titles:titles selectIndex:^(NSInteger selectIndex) {
        NSLog(@"选择了第%ld个",selectIndex);
    } selectValue:^(NSString *selectValue) {
        NSLog(@"选择的值为%@",selectValue);
        kaihuhangText.textField.text= selectValue;
    } showCloseButton:NO];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
